package com.ninong.ker.workflow.listener;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;

/**
 * @author jmz
 */
@Slf4j
public class DevTaskListener implements TaskListener {
    private static final String CREATE = "create" ;
    private static final String ASSIGNMENT = "assignment" ;
    private static final String COMPLETE = "complete" ;
    private static final String DELETE = "delete" ;

    @Override
    public void notify(DelegateTask delegateTask) {
        String eventName = delegateTask.getEventName();
        log.info("TaskListener监听到了---------------------------");
        log.info(JSON.toJSONString(delegateTask));
        log.info("TaskListener监听到了---------------------------");
        if (CREATE.endsWith(eventName)) {
            log.info("create=========");
        } else if (ASSIGNMENT.endsWith(eventName)) {
            log.info("assignment========" + delegateTask.getAssignee());
        } else if (COMPLETE.endsWith(eventName)) {
            log.info("complete===========");
        } else if (DELETE.endsWith(eventName)) {
            log.info("delete=============");
        }
    }
}
